import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/index/model/bottom_navigation.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class CustomBottomNavigationBarItem extends StatelessWidget {
  final BottomNavigation data;
  final VoidCallback onTap;
  final bool isSelected;
  final TextStyle textStyle;
  final TextStyle selectedTextStyle;

  String get icon {
    return isSelected ? data.selectedIcon : data.icon;
  }

  TextStyle get titleStyle {
    return isSelected ? selectedTextStyle ?? TextStyleConstant().selectedBottomNavigation : textStyle ?? TextStyleConstant().bottomNavigation;
  }

  const CustomBottomNavigationBarItem({
    Key key,
    @required this.data,
    this.onTap,
    this.isSelected = false,
    this.textStyle,
    this.selectedTextStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double iconSize = 50.w;

    return GestureDetector(
      onTap: onTap,
      behavior: HitTestBehavior.translucent,
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 15),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset(icon, width: iconSize, height: iconSize, fit: BoxFit.cover),
            Container(
              margin: EdgeInsets.only(top: 5.w),
              child: Text(data.title, style: titleStyle),
            ),
          ],
        ),
      ),
    );
  }
}
